﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// GetTPB, Copyright Mirosław M. Mączka.  All Rights Reserved. This code released under the terms of the Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
namespace GetTpb
{
    public class TpbSource
    {
        public string webPage { get; set; }
        public string Title { get; set; }
        public int minSize { get; set; }
        public int maxCount { get; set; }
        public string Selection { get; set; }
        //
        public TpbSource()
        {
            this.webPage = "";
            this.Title = "";
            this.minSize = 0;
            this.maxCount = 0;
            this.Selection = "";
        }
        //
        public TpbSource(string webPage, string Title, int minSize, int maxCount, string Selection)
        {
            this.webPage = webPage;
            this.Title = Title;
            this.minSize = minSize;
            this.maxCount = maxCount;
            this.Selection = Selection;
        }
        public static bool Cnv2TpbSource(string webPage, string Title, string minSize, string maxCount, string Selection, ref TpbSource ts)
        {
            webPage=webPage.Trim();
            Title=Title.Trim();
            minSize=minSize.Trim();
            maxCount=maxCount.Trim();
            Selection = Selection.Trim();
            int n;
            TpbSource _ts = new TpbSource();
            if ("" == webPage) return false; _ts.webPage = webPage;
            if ("" == Title) return false; _ts.Title = Title;
            if (!int.TryParse(minSize, out n)) return false;
            _ts.minSize = n;
            if (!int.TryParse(maxCount, out n)) return false;
            _ts.maxCount = n;
            _ts.Selection = Selection;
            //
            ts = _ts;
            //
            return true;
        }
        public override string ToString()
        {
            return string.Format("{1}={0}|{2}|{3}|{4}",webPage, Title, minSize, maxCount, Selection);
        }
    }//class
}//namespace
